package com.changcheng.project.obuupgradelogs.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.changcheng.framework.aspectj.lang.annotation.Log;
import com.changcheng.framework.aspectj.lang.enums.BusinessType;
import com.changcheng.project.obuupgradelogs.domain.AObuUpgradelogs;
import com.changcheng.project.obuupgradelogs.service.IAObuUpgradelogsService;
import com.changcheng.framework.web.controller.BaseController;
import com.changcheng.framework.web.domain.AjaxResult;
import com.changcheng.common.utils.poi.ExcelUtil;
import com.changcheng.framework.web.page.TableDataInfo;

/**
 * OBU升级记录Controller
 * 
 * @author dazhi
 * @date 2020-11-09
 */
@Controller
@RequestMapping("/obuupgradelogs/obuupgradelogs")
public class AObuUpgradelogsController extends BaseController
{
    private String prefix = "obuupgradelogs/obuupgradelogs";

    @Autowired
    private IAObuUpgradelogsService aObuUpgradelogsService;

    @RequiresPermissions("obuupgradelogs:obuupgradelogs:view")
    @GetMapping()
    public String obuupgradelogs()
    {
        return prefix + "/obuupgradelogs";
    }

    /**
     * 查询OBU升级记录列表
     */
    @RequiresPermissions("obuupgradelogs:obuupgradelogs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AObuUpgradelogs aObuUpgradelogs)
    {
        startPage();
        List<AObuUpgradelogs> list = aObuUpgradelogsService.selectAObuUpgradelogsList(aObuUpgradelogs);
        return getDataTable(list);
    }

    /**
     * 导出OBU升级记录列表
     */
    @RequiresPermissions("obuupgradelogs:obuupgradelogs:export")
    @Log(title = "OBU升级记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AObuUpgradelogs aObuUpgradelogs)
    {
        List<AObuUpgradelogs> list = aObuUpgradelogsService.selectAObuUpgradelogsList(aObuUpgradelogs);
        ExcelUtil<AObuUpgradelogs> util = new ExcelUtil<AObuUpgradelogs>(AObuUpgradelogs.class);
        return util.exportExcel(list, "obuupgradelogs");
    }

    /**
     * 新增OBU升级记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存OBU升级记录
     */
    @RequiresPermissions("obuupgradelogs:obuupgradelogs:add")
    @Log(title = "OBU升级记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AObuUpgradelogs aObuUpgradelogs)
    {
        return toAjax(aObuUpgradelogsService.insertAObuUpgradelogs(aObuUpgradelogs));
    }

    /**
     * 修改OBU升级记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AObuUpgradelogs aObuUpgradelogs = aObuUpgradelogsService.selectAObuUpgradelogsById(id);
        mmap.put("aObuUpgradelogs", aObuUpgradelogs);
        return prefix + "/edit";
    }

    /**
     * 修改保存OBU升级记录
     */
    @RequiresPermissions("obuupgradelogs:obuupgradelogs:edit")
    @Log(title = "OBU升级记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AObuUpgradelogs aObuUpgradelogs)
    {
        return toAjax(aObuUpgradelogsService.updateAObuUpgradelogs(aObuUpgradelogs));
    }

    /**
     * 删除OBU升级记录
     */
    @RequiresPermissions("obuupgradelogs:obuupgradelogs:remove")
    @Log(title = "OBU升级记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(aObuUpgradelogsService.deleteAObuUpgradelogsByIds(ids));
    }
}
